package Test.week1.Service;


import Test.week1.Utils.PhoneAndName;
import Test.week1.Utils.RandomNum;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;

public class CreateData {
    public static void main(String[] args) throws Exception {
        //小狗堂

        //趟狗小
        FileWriter fileWriter = new FileWriter(args[0]);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        ArrayList<String> phoneList = PhoneAndName.getPhoneList();
        HashMap<String, String> map = PhoneAndName.getMap();
        Random random=new Random();
        while (true){
            int callPhoneID= RandomNum.getNum();
            int calledPhoneID=0;
            boolean flag=true;
            while (flag){
                calledPhoneID=RandomNum.getNum();
                if(calledPhoneID!=callPhoneID){
                    flag=false;
                }
            }
                String callPhone = phoneList.get(callPhoneID);
                String calledPhone = phoneList.get(calledPhoneID);
                String callPeo = map.get(callPhone);
                String calledPeo = map.get(calledPhone);
                String startTime = RandomNum.getStartTime();
                String callLong = RandomNum.getCallLong();
                String result = callPhone + "\t" + callPeo + "\t" + calledPhone + "\t" + calledPeo + "\t" + startTime + "\t" + callLong+"\n";
                bufferedWriter.write(result);
                bufferedWriter.flush();
                Thread.sleep(50);
        }
    }
}
